﻿using System;
using System.Web.UI;
using OrderManage.BLL;
using OrderManage.Model;

namespace OrderManage.WebApp
{
    public partial class MobileRecharge : Page
    {

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                
            }
        }

        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btn_save_Click(object sender, EventArgs e)
        {
            var model = new OrderInfo
                            {
                                UserName = txtUserName.Value.Trim(),
                                Mobile = txtMobile.Value.Trim(),
                                RechargeAmount = Convert.ToInt32(txtRechargeAmount.Value.Trim())
                            };
            if (string.IsNullOrEmpty(model.UserName) && string.IsNullOrEmpty(model.Mobile)) return;
            var result = new OrderBLL().SaveOrder(model);
            if (result)
            {
                lblMsg.InnerHtml = "<script type='text/javascript'>alert('" + model.Mobile + "充值成功');</script>";
                txtMobile.Value = "";
                txtRechargeAmount.Value = "";
                txtMobile.Focus();
            }
            else
            {
                lblMsg.InnerHtml = "<script type='text/javascript'>alert('" + model.Mobile + "充值失败');</script>";
                txtMobile.Value = "";
                txtMobile.Focus();
            }
        }
    }
}
